package com.multithread.base;

/**
 * @author: hfxiang
 * @Description:
 * @date: 2022/7/20 11:47
 */
public class Producer  implements Runnable {
    private Queue queue;
    private Integer ratio = 500;//速率 单位豪秒
    public Producer(Queue queue){
        this.queue=queue;
    }

    private void creat()  {
        try {
            Thread.sleep(ratio);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
    private void produce(){
        creat();
        queue.purchase();
    }

    public void run() {
        while(true){
            produce();
        }
    }
}
